#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/errno.h>

//Global variables (on les déclare hors fonction)
int results = 0;
int a = 2;
int b = 3;
int temp = 0;

/**
* fonction qui passe les arguments par valeur
*/
void mySum(int x, int y){
	results = x + y;
	printf("results: %d \n", results);
}

/**
* fonction qui passe les arguments par reference
*/
void mySumByRef(int* x, int* y){
	results = *x + *y; // nous devons dereferencer la variable pour avoir acces a son contenu
 	*x = (*x)*2;//bien penser a dereferencer la variable
	*y = (*y)*2;
	printf("results: %d \n", results);
}

/**
* fonction principale
*/
int main(){

printf("-----------\n");
printf("STARTING\n");
printf("-----------\n");

printf("\n");
printf("mySum....\n");
mySum(a,b);

printf("\n");
printf("Somme a+b: %d + %d = %d \n", a, b, results);
printf("\n");


printf("\n");
printf("mySumRef....\n");
mySumByRef(&a,&b);

printf("\n");
printf("Somme a+b:  %d + %d = %d \n", a, b, results);
printf("\n");

printf("-----------\n");
printf("Exiting...\n");
printf("-----------\n");

}//main



